<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // 利用则表达式,把对象中的空值''改为null
    let obj = {
      a: 1,
      b: '',
      c: "空字符串改为null"
    }
    console.log(obj, '修改之前的obj')
    // 转为字符串
    let itemList = JSON.stringify(obj)
    //取代
    let result = itemList.replace(/""/g, "null");
    //解析
    obj = JSON.parse(result)
    console.log(obj, '修改之后的obj')
  </script>
</body>

</html>